﻿@model List<WebEntities.Models.WebInfo.ExpertCata>
@{
    ViewBag.Title = "网站管理平台_专家人物视图";
}
@section HeadContent
{
    <script type="text/javascript">
        var iframeLoad = function (grid, record) {
            var cataId = record.internalId;
            if (App.expertView.iframe != null) {
                App.expertView.iframe.dom.contentWindow.App.hidCataID.setValue(cataId);
                var imgview = App.expertView.iframe.dom.contentWindow.App.ImageView;
                imgview.store.proxy.extraParams.cataid = cataId;
                imgview.store.reload();
            }
        };
    </script>
}
@(Html.X().Menu()
    .ID("Grid1CtxMenu")
    .Items(
        Html.X().MenuItem().Text("编辑目录").Icon(Icon.BookEdit)
            .DirectEvents(de =>
            {
                de.Click.Action = "EditExpertCataWindow";
                de.Click.ExtraParams.Add(new Parameter("ExpertCataId", "this.parentMenu.dataRecord.data.ExpertCataID", ParameterMode.Raw));
            }),
            Html.X().MenuItem().Text("删除目录").Icon(Icon.Cross).Listeners(ls => ls.Click.Handler = "App.BtnDeleteSel.getEl().dom.click()")
    )
)

@Html.X().Hidden().ID("DeleteHint").Text("是否要删除选中的专家人物目录？")

@(Html.X().Viewport()
    .Layout(LayoutType.Border)
    .Items(
        Html.X().GridPanel().Region(Region.West).Split(true).Collapsible(true)
            .ID("GridPanel1")
            .Title("专家人物目录管理")
            .Store(
                Html.X().StoreForModel()
                    .AutoSync(true)
                    .PageSize(50)
                    .ShowWarningOnFailure(false)
                    .Proxy(proxy => proxy.Add(Html.X().AjaxProxy()
                            .Url(Url.Action("GetAllExpertCata"))
                        .Reader(Html.X().JsonReader().Root("data").IDProperty("ExpertCataID"))
                        .Writer(writer => new JsonWriter { AllowSingle = true, Root = "data" })
                            .API(api => { api.Destroy = Url.Action("DeleteExpertCata"); })
                    ))
                    .Listeners(ls => ls.Write.Fn = "ext.net.comjs.onGridChange")
            )
            .ColumnModel(
                Html.X().RowNumbererColumn(),
                        Html.X().Column().DataIndex(Model, m => m.ExpertCataID).Text("目录ID").Width(50),
                    Html.X().Column().DataIndex(Model, m => m.ExpertCataName).Text("目录名称")

                )
            .SelectionModel(Html.X().CheckboxSelectionModel().Mode(SelectionMode.Multi))
            .Listeners(ls =>
            {
                ls.ItemContextMenu.Handler = "e.preventDefault(); App.Grid1CtxMenu.dataRecord = this.store.getAt(index); App.Grid1CtxMenu.showAt(e.getXY());";
                ls.ItemClick.Fn = "iframeLoad";

            })
            //.View(Html.X().GridView().StripeRows(true))
            .DirectEvents(de =>
            {
                de.ItemDblClick.Action = "EditExpertCataWindow";
                de.ItemDblClick.ExtraParams.Add(new Parameter("ExpertCataId", "record.data['ExpertCataID']", ParameterMode.Raw));

            })
            .TopBar(
                Html.X().Toolbar()
                    .Items(
                            Html.X().Button().Text("新建目录").Icon(Icon.Add).DirectClickAction("NewExpertCataWindow"),
                        Html.X().Button().ID("BtnDeleteSel").Text("删除目录").Icon(Icon.Cross)
                            .Listeners(
                                ls => ls.Click.Fn = "ext.net.comjs.deleteGridSelected"
                            )
                    )
            )
            .BottomBar(
                Html.X().PagingToolbar()
                    .Items(
                        Html.X().Label("每页显示行数："),
                        Html.X().ToolbarSpacer(10),
                        Html.X().ComboBox()
                            .Width(80)
                            .Items("10", "50", "100")
                            .SelectedItems("50")
                            .Listeners(lr =>
                            {
                                lr.Select.Fn = "ext.net.comjs.onPageSizeChange";
                            })
                    )
                ), 
        Html.X().Panel().ID("expertView").Region(Region.Center)
            .Loader(
                Html.X().ComponentLoader()
                        .Url(Url.Action("Index", "Expert"))
                    .Mode(LoadMode.Frame).Params(new { cataid = 0 })
                    .LoadMask(lm =>
                    {
                        lm.ShowMask = true;
                        lm.Msg = "加载中，请稍候...";
                    })
            )

    )
)